package com.xpertline.ui.validator;

import org.jdesktop.beansbinding.Validator;

/**
 * Validate the year-of-birth field. This year can't be in the future.
 */
public final class EmailValidator extends Validator<String> {

	@Override
	public Result validate(String email) {
		if (email == null) {
			return null;
		}
		// Assigning the email format regular expression
		String emailPattern="^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})";
		if (!email.matches(emailPattern)) {
			return new Result(null, "Email is not correct format.");
		}
		return null;
	}
}
